<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2016/3/8
  Time: 13:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<html>
<head>
<title>智能锁管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <meta name="viewport"
	content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="format-detection" content="telephone=no" />
<link href="${pageContext.request.contextPath}/static/css/KeysManager/DetailsInfo.css?v=5" rel="stylesheet">
 <link rel="stylesheet" href="${pageContext.request.contextPath}/static/plugins/dropload-gh-pages/dropload.css">
 <link href="${pageContext.request.contextPath}/static/plugins/layer_mobile/need/layer.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/static/js/KeysManager/index.js?sate=3"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/dropload-gh-pages/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/jquery.form.js" ></script>
	<script src="${pageContext.request.contextPath}/static/plugins/dropload-gh-pages/dropload.min.js?date=11"></script>
	<script src="${pageContext.request.contextPath}/static/plugins/layer_mobile/layer.js" type="text/javascript"></script>
	<style type="text/css">
</style>
</head>
<body>
<div id="locklist">
	<div id="lockDetail">
	</div>
</div>
<script>
$(function(){
    var page = -1;
    var size = 5;
	var countSize =${countSize};
	
	$.ajax({
        type: 'POST',
        url: '${pageContext.request.contextPath}/admin/tlocks_pageApp.action?page=0&size=20',
        dataType: 'json',
        success: function(data){
            var arrLen = data.length;
            var result='';
            if(arrLen > 0){
                for(var i=0; i<arrLen; i++){
                    result +=gethtml(data[i]);
                }
                $('#lockDetail').append(result);
               // me.resetload();
            // 如果没有数据
            }else{
                // 锁定
                //me.lock();
                // 无数据
                //me.noData();
                $("#lockDetail").html($("#templ3").html());
                          // 为了测试，延迟1秒加载
                //me.resetload();
            }

        },
        error: function(xhr, type){
            alert('Ajax error!');
        }
    });
	
    // dropload
  /*   $('#locklist').dropload({
        scrollArea : window,
        loadDownFn : function(me){
        	if (countSize != 0 && page<countSize) {
	            page++;
			}else{
				// 锁定
                me.lock();
                // 无数据
                me.noData();
                if (countSize == 0){
					setNodate();
    			}
			}
            // 拼接HTML
            var result = '';
            $.ajax({
                type: 'POST',
                url: '${pageContext.request.contextPath}/admin/tlocks_pageApp.action?page='+page+'&size='+size,
                dataType: 'json',
                success: function(data){
                    var arrLen = data.length;
                    if(arrLen > 0){
                        for(var i=0; i<arrLen; i++){
                            result +=gethtml(data[i]);
                        }
                        $('#lockDetail').append(result);
                       // me.resetload();
                    // 如果没有数据
                    }else{
                        // 锁定
                        //me.lock();
                        // 无数据
                        //me.noData();
                        $("#lockDetail").html($("#templ3").html());
                                  // 为了测试，延迟1秒加载
                        //me.resetload();
                    }

                },
                error: function(xhr, type){
                    alert('Ajax error!');
                    // 即使加载出错，也得重置
                    me.resetload();
                }
            });
            
        }
    }); */
});
function setNodate(){
	var down = $(".dropload-noData").html();
    if(typeof(down)=="undefined"){
		var i= 0;
		var interval = setInterval(setText, 1000);
		function setText() { 
			i++; 
        	down = $(".dropload-noData").html();
            if(down==""){
				$(".dropload-noData").html("暂无数据");
				clearInterval(interval) ;
			}
			if (i > 10 || down=="暂无数据") { 
				clearInterval(interval) ;
			} 
		}
    }
}
function gethtml(datai){
	var result = '<div class="key">';
	var date = '';
	if(datai.INSTALLTIME !='' && datai.INSTALLTIME !=null){
		var arrdate = datai.INSTALLTIME.split("-");
		date = arrdate[0]+"年"+arrdate[1]+"月"+arrdate[2];
	}
	result +=  '<p class="lock-name-head"></p>'+ '<p class="lock-name">'+datai.INSTALLLOCKNAME+'</p>'
    +'<div class="item">'
    	+'<span class="designation_list">用户姓名</span>'
    	/* +'<img src="${pageContext.request.contextPath}/static/images/KeysManager/PID.png" class="icon">' */
    	+'<span class="text">'+datai.UNAME+'</span>'
    +'</div>'
    +'<div class="item">'
    +'<span class="designation_list">手机号码</span>'
	/* +'<img src="${pageContext.request.contextPath}/static/images/KeysManager/telephone.png" class="icon">' */
	+'<span class="text">'+datai.TEL+'</span>'
+'</div>'
    +'<div class="item">'
    +'<span class="designation_list">添加时间</span>'
    	/* +'<img src="${pageContext.request.contextPath}/static/images/KeysManager/log.png" class="icon">' */
    	+'<span class="text">'+date+'</span>'
	+'</div>'
	+'<div class="item">'
		+'<span class="designation_list">PID 编码</span>'
		/* +'<img src="${pageContext.request.contextPath}/static/images/KeysManager/editName.png" class="icon">' */
		+'<span class="text">'+datai.PID+'</span>'
	+'</div>'
	
	+'<button class="replace-owner last" onclick="changeUser(\''+datai.SID+'\')">转换主人管理</button>'
	+'</div>';
	return result;
}
function changeUser(sid){
	layer.open({
		title:'转换主人',
	    content: '转换主人后，原主人的所有开门权限、钥匙和开门记录将消失，请确认'
	    ,btn: ['确认', '取消']
	    ,yes: function(index){
	    	window.location.href="${pageContext.request.contextPath}/admin/tlocks_createQrcode4Transfer.action?sid="+sid;
	    }
	  });
}
</script>

<script id='templ3'>
		<div class="dropload-noData">
			<img src="${pageContext.request.contextPath}/static/images/KeysManager/no_open_door.png" class="key-icon open_pic"/>
			暂时没有数据哦
		</div>
</script>
</body>
</html>
